# -*- coding: UTF-8 -*-

import  requests,json,urllib3
requests.packages.urllib3.disable_warnings()

parm = {"account": "15507553617", "password": "123456", "fromType": "pc"}
url = "https://testpassport.rabbitpre.com/api/sso/login"
url2 = "https://bws.test.rabbitpre.com"
url3 = "https://home.test.rabbitpre.com/api/workbench/org/getCompanyInfo"

def login():
    p = requests.session()
    resu = p.post(url, json=parm,verify=False)
    repon=resu.json().get("errorCode")
    if resu.json().get("errorCode") == "SUCCESS":
        print("登录成功")
    else:
        print("登录失败")
    tp=p.get(url3,verify=False)
    if tp.json()["success"] == "true":
        userid=tp.json()["data"]["org_user"]
        orgid=tp.json()["data"]["org_user"]
        print(userid,orgid)
    else:
        print("登录已失效或接口异常")
    print(tp.text)


if __name__ == '__main__':
    login()